const path = require("path"); // 导入node的path模块
function resolve(dir) {
  return path.join(__dirname, dir);
}
// 修改webpack默认配置 https://cli.vuejs.org/zh/guide/webpack.html#%E7%AE%80%E5%8D%95%E7%9A%84%E9%85%8D%E7%BD%AE%E6%96%B9%E5%BC%8F
// 我们使用链式操作 (高级)
module.exports = {
  chainWebpack(config) {
    // 设置 svg-sprite-loader
    config.module.rule("svg").exclude.add(resolve("src/icons")).end();
    config.module
      .rule("icons")
      .test(/\.svg$/)
      .include.add(resolve("src/icons"))
      .end()
      .use("svg-sprite-loader")
      .loader("svg-sprite-loader")
      .options({
        symbolId: "icon-[name]"
      })
      .end();
  },
  devServer: {
    client:{ // 解决页面报错：ResizeObserver loop completed with undelivered notifications.
      overlay: false
    },
    proxy: {
      "/api": {
        target: "https://api.imooc-admin.lgdsunday.club",
        changeOrigin: true
      }
    },

  },
  configureWebpack: {
    resolve: {
      fallback: {
        path: require.resolve("path-browserify")
      }
    }
  }
};
